home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / ANSI Headers / stat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-14  |  2.4 KB  |  96 lines  |  [TEXT/MMCC]

  1. /*
  2.  *    File:        stat.h
  3.  *                ©1993-1995 metrowerks Inc. All rights reserved
  4.  *    Author:        Berardino E. Baratta
  5.  *
  6.  *    Content:    Interface file to standard UNIX-style entry points ...
  7.  *
  8.  *    NB:            This file implements some UNIX low level support.  These functions
  9.  *                are not guaranteed to be 100% conformant.
  10.  */
  11.  
  12. #ifndef    _STAT
  13. #define    _STAT
  14.  
  15. #ifndef _TIME
  16. #include <time.h>
  17. #endif
  18.  
  19. /*
  20.  *    Local typedefs for stat struct
  21.  */
  22. typedef unsigned long    mode_t;
  23. typedef unsigned long    ino_t;
  24. typedef unsigned long    dev_t;
  25. typedef short            nlink_t;
  26. typedef unsigned long    uid_t;
  27. typedef unsigned long    gid_t;
  28. typedef long            off_t;
  29.  
  30. #pragma options align=mac68k
  31.  
  32. /*
  33.  *    (stat) st_mode bit values (only ones relevant for the Mac)
  34.  *    NB: all modes marked as (GUSI) mean that the mode is used only by GUSI
  35.  *        (Grand Unified Sockets Interface).
  36.  */
  37. #define S_IFMT        0x0F00        /* type of file */
  38. #define   S_IFCHR    0x0200        /*   character special (GUSI) */
  39. #define   S_IFDIR    0x0400        /*   directory */
  40. #define   S_IFREG    0x0800        /*   regular */
  41. #define   S_IFLNK    0x0A00        /*   symbolic link */
  42. #define   S_IFSOCK    0x0E00        /*   socket (GUSI) */
  43.  
  44. /*
  45.  *    File type macros
  46.  */
  47. #define S_ISFIFO(m)    (((m)&(_S_IFMT)) == (_S_IFIFO))
  48. #define S_ISDIR(m)    (((m)&(_S_IFMT)) == (_S_IFDIR))
  49. #define S_ISCHR(m)    (((m)&(_S_IFMT)) == (_S_IFCHR))
  50. #define S_ISBLK(m)    (((m)&(_S_IFMT)) == (_S_IFBLK))
  51. #define S_ISREG(m)    (((m)&(_S_IFMT)) == (_S_IFREG))
  52.  
  53. struct stat
  54. {
  55.     mode_t        st_mode;        /* File mode; see #define's below */
  56.     ino_t        st_ino;            /* File serial number */
  57.     dev_t        st_dev;            /* ID of device containing this file */
  58.     nlink_t        st_nlink;        /* Number of links */
  59.     uid_t        st_uid;            /* User ID of the file's owner */
  60.     gid_t        st_gid;            /* Group ID of the file's group */
  61.     dev_t        st_rdev;        /* Device type */
  62.     off_t        st_size;        /* File size in bytes */
  63.     time_t        st_atime;        /* Time of last access */
  64.     time_t        st_mtime;        /* Time of last data modification */
  65.     time_t        st_ctime;        /* Time of last file status change */
  66.     long        st_blksize;        /* Optimal blocksize */
  67.     long        st_blocks;        /* blocks allocated for file */
  68. };
  69.  
  70. #ifdef __cplusplus
  71. extern "C" {
  72. #endif
  73.  
  74. /*
  75.  *    Get state information on a file.
  76.  */
  77. int stat(const char *path, struct stat *buf);
  78.  
  79. /*
  80.  *    Get state information on an open file.
  81.  */
  82. int fstat(int fildes, struct stat *buf);
  83.  
  84. /*
  85.  *    Create a directory (mode is ignored on the mac).
  86.  */
  87. int mkdir(const char *path, int mode);
  88.  
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92.  
  93. #pragma options align=reset
  94.  
  95. #endif
  96.